package com.choosefine.springboot.devops.base.moudle.mp;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * Created by 邱鹏 on 2016/8/23.
 */
@Controller
@RequestMapping("/wechat/mp")
public class MpController {
    Logger log = LoggerFactory.getLogger("微信/check");
    ObjectMapper mapper = new ObjectMapper();
    @Autowired
    JdbcTemplate jdbcTemplate;

    @GetMapping("/")
    public String doFilter(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException, NoSuchFieldException {
        List result = jdbcTemplate.queryForList("select * from mp_wechat_manager");
        return mapper.writeValueAsString(result);
    }
}
